home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / demostuf / pattern1.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-07-25  |  2.8 KB  |  177 lines

  1. program assemblergogo;
  2. {
  3.     Patterns
  4.     - by Bjarke Viksφe
  5.     mar 1993
  6.  
  7.     My first demostuff ever on PC I think.
  8.     Old Amiga idea - doesn't go protected-mode though.
  9.  
  10.     Formula is x*x + y*y or something...
  11. }
  12.  
  13.  
  14. const
  15.     width = 320;
  16.  
  17. var
  18.    oldmode, oldpage : shortint;
  19.    i, j             : integer;
  20.    ytaller          : integer;
  21.    xtabel           : array [0..319] of integer;
  22.    ytabel           : array [0..255] of integer;
  23.  
  24.  
  25. (*-----------------------------------------------------------*)
  26.  
  27. procedure VBLANK;
  28. begin
  29.      asm
  30.       mov     dx,$3DA
  31. @vent1:
  32.      in      al,dx
  33.      test    al,8
  34.      jz      @vent1
  35. @vent2:
  36.      in      al,dx
  37.       test    al,8
  38.      jnz     @vent2
  39.      end;
  40. end;
  41.  
  42.  
  43. (*-----------------------------------------------------------*)
  44.  
  45. procedure SetColor(nr : integer; r,g,b : byte);
  46. begin
  47.      asm
  48.      mov    bx,nr
  49.      mov    cl,r
  50.       mov    ch,g
  51.      mov    dh,b
  52.      mov    ax,$1010
  53.      int    $10
  54.      end;
  55. end;
  56.  
  57. procedure OpenScreen;
  58. var
  59.    i, color : integer;
  60. begin
  61.     asm
  62.     mov     ah,$0F
  63.     int     $10
  64.     mov     oldmode,al
  65.  
  66.     mov     al,$13
  67.     xor     ah,ah
  68.     int     $10
  69.     end;
  70.  
  71.     color := 0;
  72.     for i:=1 to 63 do
  73.     begin
  74.          SetColor(i, color,color,color);
  75.          inc(color);
  76.     end;
  77.      for i:=64 to 127 do
  78.     begin
  79.          SetColor(i, color,color,color);
  80.          dec(color);
  81.     end;
  82. end;
  83.  
  84. procedure CloseScreen;
  85. begin
  86.      asm
  87.      mov    al,oldmode
  88.      xor    ah,ah
  89.      int    $10
  90.       end;
  91. end;
  92.  
  93.  
  94. (*-----------------------------------------------------------*)
  95.  
  96. procedure SetupDemo;
  97. begin
  98.      for i:=0 to 319 do
  99.          xtabel[i]:=sqr(i-160);
  100.  
  101.      for i:=0 to 199 do
  102.          ytabel[i]:=sqr(i-100);
  103. end;
  104.  
  105. (*-----------------------------------------------------------*)
  106.  
  107. procedure MakePattern(value : byte);
  108. begin
  109.     ytaller := 200;
  110.     asm
  111.     mov     ax,$A000
  112.     mov     es,ax
  113.     mov     si,0
  114.  
  115.     mov     cl,value
  116.     mov        ch,127
  117. @yloop:
  118.     mov     dl,160
  119.     lea     di,xtabel
  120. @xloop1:
  121.     mov     bx,WORD PTR ytabel
  122.     add     bx,[di]
  123.     mov     ax,bx
  124.     shr     ax,cl
  125.     and     al,ch
  126.     mov     [es:si],al
  127.     inc     si
  128.     inc     di
  129.     inc     di
  130.  
  131. @xloop2:
  132.     mov     bx,WORD PTR ytabel
  133.     add     bx,[di]
  134.     mov     ax,bx
  135.     shr     ax,cl
  136.     and     al,ch
  137.     mov     [es:si],al
  138.     inc     si
  139.     inc     di
  140.     inc     di
  141.     dec     dl
  142.     jnz     @xloop1
  143.  
  144.     add     WORD PTR @xloop1+2,2
  145.     add     WORD PTR @xloop2+2,2
  146.     dec     ytaller
  147.     jnz     @yloop
  148.  
  149.     lea     si,ytabel
  150.     mov     WORD PTR @xloop1+2, si
  151.     mov     WORD PTR @xloop2+2, si
  152.     end;
  153. end;
  154.  
  155.  
  156.  
  157. begin
  158.      SetupDemo;
  159.      OpenScreen;
  160.  
  161.      for j:=1 to 4 do
  162.      begin
  163.          for i:=0 to 16 do
  164.          begin
  165.             {VBLANK;}
  166.             MakePattern(i);
  167.          end;
  168.          for i:=15 downto 1 do
  169.          begin
  170.             {VBLANK;}
  171.             MakePattern(i);
  172.         end;
  173.     end;
  174.  
  175.     CloseScreen;
  176. end.
  177.